package com.hxtec.polaris.controller;

import com.hxtec.polaris.entity.ShopHistory;
import com.hxtec.polaris.service.HistoryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Describtion 历史记录相关
 * @Author yonyong
 * @Date 2019/11/25 16:38
 * @Version 1.0.0
 **/
@RestController
@RequestMapping(value = "history",produces = "application/json;charset=utf-8")
@CrossOrigin
@Api(value = "/history", tags = "历史记录相关")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    /**
     * 上限30条，只取最新10条
     * @return
     */
    @GetMapping("get")
    public Object getAll(){
        return historyService.getAll();
    }

    @PostMapping("insert")
    public Object insert(HttpServletRequest request,ShopHistory shopHistory){
        return historyService.insert(request,shopHistory);
    }

    @DeleteMapping("del")
    public Object del(ShopHistory shopHistory){
        return historyService.delete(shopHistory);
    }

    @DeleteMapping("delAll")
    public Object delAll(){
        return historyService.deleteAll();
    }
}
